package common.splitpage.sql;

import common.splitpage.Condition;
import common.splitpage.PageInfo;

public class MySqlPageSql implements IPageSql {

	private Condition condition;
	private String sql;
	
	public MySqlPageSql(PageInfo pageInfo) {
		this.condition = pageInfo.getCondition();
		this.sql = condition.getSql();
	}

	public String getPageSql() {
		int startRow = condition.getStartRow()-1;//从0算起,所以要减1
		if(startRow < 0) startRow = 0;
		int pageRowCount = condition.getPageRowCount();
		return this.sql + " limit " + startRow + "," + pageRowCount;
	}
}
